const express = require('express');
const cookieParser = require('cookie-parser');
const cookieSession = require('cookie-session');

var servers = express();

servers.use(cookieParser("123456"));

servers.use(cookieSession({
    keys : ['123','3456780','312123'],
    // name : 'sess',
}));

// cookie
servers.use('/',function (req,res,next) {
    req.secret='123456';
    res.cookie('user','123',{path:'/',maxAge:5*1000,signed:true});
    res.cookie('id','555',{path:'/',signed:true});
    res.cookie('rrs','1312308948');    
    res.send("hello");
    // console.log(req.cookies);
    // console.log(req.signedCookies);
    next();
}); 

// session
servers.use('/',function (req,res,next) {
    if (req.session['count']==null) 
        req.session['count'] = 1;
    else req.session['count'] ++;
    console.log(req.session);
    res.end("isOk");
})

servers.listen(3000);